package health.lm.com.find.model;

import org.json.JSONObject;

import health.lm.com.data.App;
import health.lm.com.data.HttpCST;
import health.lm.com.find.entity.EvaluationEntity;
import health.lm.com.find.entity.HActivityEntity;
import health.lm.com.find.entity.HActivityItemEntity;
import health.lm.com.find.entity.MemberAffiliateEntity;
import health.lm.com.find.entity.MemberAffiliateItemEntity;
import health.lm.com.find.entity.MerchantsEntity;
import health.lm.com.find.entity.QRCodeEntity;
import health.lm.com.network.EasyHttp;
import health.lm.com.network.callback.SimpleCallBack;
import health.lm.com.network.utils.MyApi;

/**
 * Created by Android Studio .
 * 作者：zhong
 * 日期：2018/12/6
 * 邮箱：15206394364@163.com
 * 介绍：
 * 修订：====================
 */
public class ExperienceModel {
    private static ExperienceModel model;

    public static ExperienceModel getInstance() {
        if (null == model) {
            model = new ExperienceModel();
        }
        return model;
    }


    /**
     * 修改手机号
     *
     * @param observer observer
     */
    public void shopEvaluation(String order_id, int star, String content,SimpleCallBack< Object> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            jsonObject.put("order_id", order_id);
            jsonObject.put("star", star);
            jsonObject.put("content", content);
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_ORDER, HttpCST.INTFC_1003, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }
    /**
     * 活动分类
     *
     * @param observer observer
     */
    public void hActivity(SimpleCallBack<HActivityEntity> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_ACTIVE, HttpCST.INTFC_1009, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }
    /**
     * 活动列表
     *
     * @param observer observer
     */
    public void hActivityList(String category_id,  int page, int pageSize,SimpleCallBack<HActivityItemEntity> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            jsonObject.put(HttpCST.PAGE, page);
            jsonObject.put("category_id", category_id);
            jsonObject.put(HttpCST.PAGE_SIZE, pageSize);
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_ACTIVE, HttpCST.INTFC_1001, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }
    /**
     * 联盟商分类
     *
     * @param observer observer
     */
    public void lms(SimpleCallBack<MemberAffiliateEntity> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_UNION, HttpCST.INTFC_1007, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }
    /**
     * 联盟商列表
     *
     * @param observer observer
     */
    public void lmsList(String category_id,  int page, int pageSize,SimpleCallBack<MemberAffiliateItemEntity> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            jsonObject.put(HttpCST.PAGE, page);
            jsonObject.put("category_id", category_id);
            jsonObject.put(HttpCST.PAGE_SIZE, pageSize);
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_UNION, HttpCST.INTFC_1001, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }
    /**
     * 联盟商详情
     * @param observer observer
     */
    public void merchants(String union_id, SimpleCallBack<MerchantsEntity> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            jsonObject.put("union_id", union_id);
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_UNION, HttpCST.INTFC_1002, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }
    /**
     * 联盟商评论列表
     *
     * @param observer observer
     */
    public void evaluation(String union_id,  int page, int pageSize,SimpleCallBack<EvaluationEntity> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            jsonObject.put(HttpCST.PAGE, page);
            jsonObject.put("union_id", union_id);
            jsonObject.put(HttpCST.PAGE_SIZE, pageSize);
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_UNION, HttpCST.INTFC_1008, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }
    /**
     * 活动评价
     * @param observer observer
     */
    public void evaluationPop(String active_id,int content_star,int quality_star,int process_star,
                              int value_star,int server_star,int join_star, SimpleCallBack<Object> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            jsonObject.put("active_id", active_id);
            jsonObject.put("content_star", content_star);
            jsonObject.put("quality_star", quality_star);
            jsonObject.put("process_star", process_star);
            jsonObject.put("value_star", value_star);
            jsonObject.put("server_star", server_star);
            jsonObject.put("join_star", join_star);
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_ACTIVE, HttpCST.INTFC_1008, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }

    /**
     * __Active_ - 【1011】查看核销码
     */
    public void viewQrCode(String active_id ,SimpleCallBack<QRCodeEntity> observer) {
        JSONObject jsonObject = new JSONObject();
        String json = "";
        try {
            jsonObject.put(HttpCST.ACCESS_TOKEN, App.getModel().getAccess_token());
            jsonObject.put("active_id", active_id);
            json = MyApi.getInstance().generateMessage(HttpCST.MODULE_ACTIVE, HttpCST.INTFC_1011, jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
        EasyHttp.post("/").upJson(json).execute(observer);
    }
}
